#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    long long c = 0, ch = 0, chn = 0;
    char s[8001];
    scanf("%s\n", s);
    char* p = s;
    while (*p) {
        if (*p == 'C') {
            c++;
        }
        if (*p == 'H') {
            ch += c;
        }
        if (*p == 'N') {
            chn += ch;
        }
        p++;
    }
    printf("%lld\n", chn);
    return 0;
}